import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)

const originalPush = VueRouter.prototype.push

VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}


const routes = [
    {
        path: '/',
        name: 'Home',
        component: resolve => require(['../views/Home.vue'], resolve),
        children: [
            {
                path: '/',
                name: 'Manager',
                component: resolve => require(['../layout/Manager.vue'], resolve),
                children: [
                    {
                        path: '/',
                        name: 'CodeSquare',
                        component: resolve => require(['../views/CodeSquare.vue'], resolve)
                    },
                    {
                        path: '/search',
                        name: 'Search',
                        component: resolve => require(['../views/Search.vue'], resolve)
                    },
                    {
                        path: '/yourwork',
                        name: 'YourWork',
                        component: resolve => require(['../views/YourWork.vue'], resolve)
                    },
                    {
                        path: '/myvscode',
                        name: 'MyVsCode',
                        component: resolve => require(['../views/MyVsCode.vue'], resolve)
                    },
                    {
                        path: '/account',
                        name: 'Account',
                        component: resolve => require(['../views/Account.vue'], resolve)
                    }
                ]
            },
            {
                path: '/codeshow',
                name: 'CodeShow',
                component: resolve => require(['../views/CodeShow.vue'], resolve)
            },
            {
                path: '/desktop',
                name: 'Desktop',
                component: resolve => require(['../views/Desktop.vue'], resolve)
            }

        ]
    }
]

const router = new VueRouter({
    routes
})

export default router
